package com.shoppingmall.activity.mine;

import android.os.Bundle;
import android.view.View;

import com.allen.library.SuperTextView;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.zyh.toolslib.base.BaseActivity;
import com.example.zyh.toolslib.widget.TitleBar;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import com.shoppingmall.R;
import com.shoppingmall.bean.DealersBean;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 2020/3/14
 * 描述：我的经销商
 */
public class MineDealersActivity extends BaseActivity {
    @BindView(R.id.title_bar)
    TitleBar titleBar;
    @BindView(R.id.rv_content_list)
    RecyclerView rvContentList;
    @BindView(R.id.smart_refresh)
    SmartRefreshLayout smartRefresh;

    private List<DealersBean> mData = new ArrayList<>();
    private BaseQuickAdapter<DealersBean, BaseViewHolder> mAdapter;

    @Override
    protected int initLayout() {
        return R.layout.activity_mine_my_dealers;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        for (int i = 0; i < 5; i++) {
            mData.add(new DealersBean("18235899625", "150"));
        }
        mAdapter = new BaseQuickAdapter<DealersBean, BaseViewHolder>(R.layout.item_mine_my_dealers, mData) {
            @Override
            protected void convert(@NonNull BaseViewHolder helper, DealersBean item) {
                SuperTextView superTextView = (SuperTextView) helper.itemView;
                superTextView.setLeftString(item.getAccountNumber());
                superTextView.setRightString("重消币：" + item.getConsumeCoins());
            }
        };
        rvContentList.setLayoutManager(new LinearLayoutManager(mContext));
        rvContentList.setAdapter(mAdapter);
    }

    @Override
    protected void initEvent() {
        titleBar.setLeftLayoutClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        smartRefresh.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

            }
        });
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ActivityUtils.startActivity(MineDealersDetailsActivity.class);
            }
        });
    }

}
